package com.huang.controller;

import com.huang.vo.HelloReqVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


@Slf4j
@RestController
public class HelloController {

    @GetMapping("/sayGet")
    public String sayGet(@RequestParam("name") String name,
                         @RequestParam("age") Integer age) {
        log.info("name:{},age:{}", new Object[]{name, age});
        return "OK";
    }

    @PostMapping(value = "/sayPost", produces = "application/json;charset=UTF-8")
    public String sayPost(@RequestBody HelloReqVo reqVo) {
        log.info("HelloReqVo:{}", new Object[]{reqVo});
        return "OK";
    }

    @PostMapping("/sayFile")
    public String sayFile(@RequestPart("file") MultipartFile file) {
        log.info("file:{}", new Object[]{file});
        log.info("fileName:{}", new Object[]{file.getOriginalFilename()});
        return "OK";
    }
}
